package com.bst.web.base;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bst.common.annotation.Log;
import com.bst.common.enums.BusinessType;
import com.bst.base.domain.BaseReportDate;
import com.bst.base.service.IBaseReportDateService;
import com.bst.common.core.controller.BaseController;
import com.bst.common.core.domain.AjaxResult;
import com.bst.common.utils.poi.ExcelUtil;
import com.bst.common.core.page.TableDataInfo;

/**
 * 通用上报时间Controller
 * 
 * @author ruoyi
 * @date 2024-05-07
 */
@Controller
@RequestMapping("/base/report/date")
public class BaseReportDateController extends BaseController
{
    private String prefix = "base/report";

    @Autowired
    private IBaseReportDateService baseReportDateService;

    @GetMapping()
    public String date()
    {
        return prefix + "/date";
    }

    /**
     * 查询通用上报时间列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseReportDate baseReportDate)
    {
        startPage();
        List<BaseReportDate> list = baseReportDateService.selectBaseReportDateList(baseReportDate);
        return getDataTable(list);
    }

    /**
     * 新增通用上报时间
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存通用上报时间
     */
    @RequiresPermissions("base:date:add")
    @Log(title = "通用上报时间", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BaseReportDate baseReportDate)
    {
        return toAjax(baseReportDateService.insertBaseReportDate(baseReportDate));
    }

    /**
     * 修改通用上报时间
     */
    @GetMapping("/edit/{idReport}")
    public String edit(@PathVariable("idReport") Long idReport, ModelMap mmap)
    {
        BaseReportDate baseReportDate = baseReportDateService.selectBaseReportDateByIdReport(idReport);
        mmap.put("baseReportDate", baseReportDate);
        return prefix + "/edit";
    }

    /**
     * 修改保存通用上报时间
     */
    @Log(title = "通用上报时间", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BaseReportDate baseReportDate)
    {
        return toAjax(baseReportDateService.updateBaseReportDate(baseReportDate));
    }

    /**
     * 删除通用上报时间
     */
    @Log(title = "通用上报时间", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(baseReportDateService.deleteBaseReportDateByIdReports(ids));
    }
}
